//
//  ModifyAndAddSubView.m
//  HondaPro_2
//
//  Created by ht on 13-7-18.
//  Copyright (c) 2013年 glendale. All rights reserved.
//

#import "ModifyAndAddSubView.h"
#import <QuartzCore/QuartzCore.h>
#import "webService.h"
#import "webConfig.h"
#import "HUD/SVProgressHUD.h"
#import "MyAFNetWorkManager.h"
#import "SVProgressHUD.h"

#define NUMBERS @"0123456789\n"
@implementation ModifyAndAddSubView
{
    BOOL _chooes1;
    BOOL _chooes2;
    BOOL _chooes3;
    BOOL _chooes4;
    BOOL _chooes5;
    BOOL _chooes6;
    BOOL _chooes7;
}

@synthesize modifyDit = _modifyDit;

- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self)
    {
        [self fixedTitle];
        [self addNotification];
        
    }
    return self;
}
-(void)drawRect:(CGRect)rect{
//    webService *webcon = [[webService alloc] init];
//    webcon.methodName = GETWORKSTATIONLIST;
//    NSMutableArray *arry = [NSMutableArray arrayWithObjects:@"workshopType",self.gChangNumber,nil];
//    [webcon commonGetSharedRequest:GETWORKSTATIONLIST wsparas:arry];
    if (!contentCon) {
        contentCon=[[popContentViewController alloc] initWithNibName:@"popContentViewController" bundle:nil];
    }
    contentCon.delegate = self;
    contentCon.btnSender=self.gWeiName;
//    self.popCon = [[UIPopoverController alloc] initWithContentViewController:contentCon];
//    [DDPopoverBackgroundView setTintColor:[UIColor colorWithRed:234 green:248 blue:242 alpha:0.9]];
//    [DDPopoverBackgroundView setArrowBase:30.0];//箭头
//    [DDPopoverBackgroundView setArrowHeight:15.0];
//    [DDPopoverBackgroundView setContentInset:1.0];
//    [self.popCon setPopoverBackgroundViewClass:[DDPopoverBackgroundView class]];
//    [self.popCon setPopoverContentSize:CGSizeMake(self.gWeiName.frame.size.width, 280)];

//    [self gWeiName:self.gWeiName];
////    [self selectDelegate:1 btn:nil];
//    
//    [self.popCon dismissPopoverAnimated:YES];
//    self.popCon = nil;
}
-(void)callTextButton
{
    //预约号
    self.yYueNumber = [[UILabel alloc]initWithFrame:CGRectMake(115, 100, 210, 30)];
    [self.yYueNumber setBackgroundColor:[UIColor clearColor]];
    self.yYueNumber.layer.borderColor = [[UIColor grayColor]CGColor];
    self.yYueNumber.layer.borderWidth = 0.8;
    self.yYueNumber.textColor = [UIColor grayColor];
    self.yYueNumber.text = [self.modifyDit valueForKey:@"precontractId"];
    [self.yYueNumber setTextAlignment:NSTextAlignmentCenter];
    self.yYueNumber.font = [UIFont fontWithName:@"ArialMT" size:16];
    [self addSubview:self.yYueNumber];
    
    //车牌号码
    self.cPaiNumber = [[UITextField alloc]initWithFrame:CGRectMake(115, 150, 160, 30)];
    self.cPaiNumber.borderStyle = UITextBorderStyleLine;
    self.cPaiNumber.font = [UIFont fontWithName:@"ArialMT" size:16];
    self.cPaiNumber.textColor = [UIColor grayColor];
    //[self.cPaiNumber setPlaceholder:@"查询条件大于两位"];
    self.cPaiNumber.text = [self.modifyDit valueForKey:@"plateNumber"];
//    self.cPaiNumber.clearsOnBeginEditing = YES;
    [self.cPaiNumber setTextAlignment:NSTextAlignmentCenter];
    self.cPaiNumber.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;
    [self addSubview:self.cPaiNumber];
    //车牌查询
    self.carPlateCxun = [[UIButton alloc]initWithFrame:CGRectMake(280, 148, 47, 35)];
    [self.carPlateCxun setTitle:@"🔍" forState:UIControlStateNormal];
    [self.carPlateCxun setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    //    [self.carPlateCxun setBackgroundImage:[UIImage imageNamed:@"ht05-1.png"] forState:UIControlStateNormal];
    self.carPlateCxun.titleLabel.font = [UIFont fontWithName:@"ArialMT" size:23];
    [self.carPlateCxun addTarget:self action:@selector(carPlateCxun:) forControlEvents:UIControlEventTouchUpInside];
    [self addSubview:self.carPlateCxun];
    //客户名称
    self.kHuName = [[UITextField alloc]initWithFrame:CGRectMake(115, 200, 210, 30)];
    self.kHuName.borderStyle = UITextBorderStyleLine;
    self.kHuName.font = [UIFont fontWithName:@"ArialMT" size:16];
    self.kHuName.textColor = [UIColor grayColor];
    self.kHuName.text = [self.modifyDit valueForKey:@"customerName"];
    [self.kHuName setTextAlignment:NSTextAlignmentCenter];
    self.kHuName.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;
    [self addSubview:self.kHuName];
    //用户陈述
    self.yHuSpeak = [[UITextView alloc]initWithFrame:CGRectMake(115, 250, 525, 65)];
    self.yHuSpeak.font = [UIFont fontWithName:@"ArialMT" size:15];
    self.yHuSpeak.layer.borderColor = [[UIColor grayColor]CGColor];
    self.yHuSpeak.layer.borderWidth = 0.8;
    self.yHuSpeak.textColor = [UIColor grayColor];
    self.yHuSpeak.text = [self.modifyDit valueForKey:@"customerDescription"];
    [self addSubview:self.yHuSpeak];
    //修理类型
    self.xLiType = [[UIView alloc]initWithFrame:CGRectMake(115, 330, 525, 75)];
    self.xLiType.layer.borderColor = [[UIColor grayColor]CGColor];
    self.xLiType.layer.borderWidth = 0.8;
    [self addSubview:self.xLiType];
    //工厂
    UILabel *label2 = [[UILabel alloc]initWithFrame:CGRectMake(115, 420, 105, 30)];
    [label2 setBackgroundColor:[UIColor whiteColor]];
    label2.layer.borderColor = [[UIColor grayColor]CGColor];
    label2.layer.borderWidth = 0.8;
    [self addSubview:label2];
    self.gWei = [[UIButton alloc]initWithFrame:CGRectMake(116, 421, 103, 28)];
    [self.gWei setBackgroundImage:[UIImage imageNamed:@"下拉框.png"] forState:UIControlStateNormal];
    [self.gWei addTarget:self action:@selector(gWei:) forControlEvents:UIControlEventTouchUpInside];
    [self.gWei setTitle:[self.modifyDit valueForKey:@"factoryName"] forState:UIControlStateNormal];
    self.gWei.titleLabel.font = [UIFont fontWithName:@"ArialMT" size:14];
    [self.gWei setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
    [self.gWei setTag:1];
    [self addSubview:self.gWei];
    //工位
    UILabel *label3 = [[UILabel alloc]initWithFrame:CGRectMake(225, 420, 100, 30)];
    [label3 setBackgroundColor:[UIColor whiteColor]];
    label3.layer.borderColor = [[UIColor grayColor]CGColor];
    label3.layer.borderWidth = 0.8;
    [self addSubview:label3];
    self.gWeiName = [[UIButton alloc]initWithFrame:CGRectMake(226, 421, 98, 28)];
    [self.gWeiName setBackgroundImage:[UIImage imageNamed:@"下拉框.png"] forState:UIControlStateNormal];
    [self.gWeiName addTarget:self action:@selector(gWeiName:) forControlEvents:UIControlEventTouchUpInside];
    [self.gWeiName setTitle:self.chuanGweiName forState:UIControlStateNormal];
//    [self.gWeiName setTitle:[self.modifyDit objectForKey:@"workStationName"] forState:UIControlStateNormal];
    self.gWeiName.titleLabel.font = [UIFont fontWithName:@"ArialMT" size:14];
    [self.gWeiName setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
    [self.gWeiName setTag:1];
    [self addSubview:self.gWeiName];
    //开始时间
    UILabel *label4 = [[UILabel alloc]initWithFrame:CGRectMake(115, 470, 210, 30)];
    [label4 setBackgroundColor:[UIColor whiteColor]];
    label4.layer.borderColor = [[UIColor grayColor]CGColor];
    label4.layer.borderWidth = 0.8;
    [self addSubview:label4];
    self.beginTime = [[UIButton alloc]initWithFrame:CGRectMake(116, 471, 208, 28)];
    [self.beginTime setBackgroundImage:[UIImage imageNamed:@"下拉框.png"] forState:UIControlStateNormal];
    [self.beginTime addTarget:self action:@selector(beginTime:) forControlEvents:UIControlEventTouchUpInside];
    [self.beginTime setTitle:[self.modifyDit valueForKey:@"startTime"] forState:UIControlStateNormal];
    self.beginTime.titleLabel.font = [UIFont fontWithName:@"ArialMT" size:16];
    [self.beginTime setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
    [self addSubview:self.beginTime];
    //登记人
    self.dJPeopleLabel = [[UILabel alloc]initWithFrame:CGRectMake(115, 520, 210, 30)];
    [self.dJPeopleLabel setBackgroundColor:[UIColor clearColor]];
    self.dJPeopleLabel.layer.borderColor = [[UIColor grayColor]CGColor];
    self.dJPeopleLabel.layer.borderWidth = 0.8;
    self.dJPeopleLabel.text = [self.modifyDit valueForKey:@"inputPersonName"];
    self.dJPeopleLabel.font = [UIFont fontWithName:@"ArialMT" size:16];
    [self.dJPeopleLabel setTextAlignment:NSTextAlignmentCenter];
    self.dJPeopleLabel.textColor = [UIColor grayColor];
    [self addSubview:self.dJPeopleLabel];
    //预约类型
    self.yYueTypeLabel = [[UILabel alloc]initWithFrame:CGRectMake(430, 100, 210, 30)];
    [self.yYueTypeLabel setBackgroundColor:[UIColor clearColor]];
    self.yYueTypeLabel.layer.borderColor = [[UIColor grayColor]CGColor];
    self.yYueTypeLabel.layer.borderWidth = 0.8;
    self.yYueTypeLabel.text = @"用户来电";
    self.yYueTypeLabel.font = [UIFont fontWithName:@"ArialMT" size:16];
    [self.yYueTypeLabel setTextAlignment:NSTextAlignmentCenter];
    self.yYueTypeLabel.textColor = [UIColor grayColor];
    [self addSubview:self.yYueTypeLabel];
    //车架号
    self.cJiaNumber = [[UITextField alloc]initWithFrame:CGRectMake(430, 150, 210, 30)];
    self.cJiaNumber.borderStyle = UITextBorderStyleLine;
    self.cJiaNumber.font = [UIFont fontWithName:@"ArialMT" size:16];
    self.cJiaNumber.textColor = [UIColor grayColor];
    self.cJiaNumber.text = [self.modifyDit valueForKey:@"vin"];
    [self.cJiaNumber setTextAlignment:NSTextAlignmentCenter];
    self.cJiaNumber.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;
    [self addSubview:self.cJiaNumber];
    //联系电话
    self.lXiPhone = [[UITextField alloc]initWithFrame:CGRectMake(430, 200, 210, 30)];
    self.lXiPhone.borderStyle = UITextBorderStyleLine;
    self.lXiPhone.font = [UIFont fontWithName:@"ArialMT" size:16];
    self.lXiPhone.textColor = [UIColor grayColor];
    self.lXiPhone.text = [self.modifyDit valueForKey:@"mobile"];
    [self.lXiPhone setTextAlignment:NSTextAlignmentCenter];
    self.lXiPhone.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;
    self.lXiPhone.clearsOnBeginEditing = YES;
    self.lXiPhone.keyboardType = UIKeyboardTypeNumberPad;
    self.lXiPhone.delegate = self;
    [self addSubview:self.lXiPhone];
    //服务顾问
    UILabel *label8 = [[UILabel alloc]initWithFrame:CGRectMake(430, 420, 210, 30)];
    [label8 setBackgroundColor:[UIColor whiteColor]];
    label8.layer.borderColor = [[UIColor grayColor]CGColor];
    label8.layer.borderWidth = 0.8;
    [self addSubview:label8];
    self.fWuConsultant = [[UIButton alloc]initWithFrame:CGRectMake(431, 421, 208, 28)];
    [self.fWuConsultant setBackgroundImage:[UIImage imageNamed:@"下拉框.png"] forState:UIControlStateNormal];
    [self.fWuConsultant addTarget:self action:@selector(fWuConsultant:) forControlEvents:UIControlEventTouchUpInside];
    [self.fWuConsultant setTitle:[self.modifyDit valueForKey:@"saName"] forState:UIControlStateNormal];
    self.fWuConsultant.titleLabel.font = [UIFont fontWithName:@"ArialMT" size:16];
    [self.fWuConsultant setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
    [self addSubview:self.fWuConsultant];
    //结束时间
    UILabel *label9 = [[UILabel alloc]initWithFrame:CGRectMake(430, 470, 210, 30)];
    [label9 setBackgroundColor:[UIColor whiteColor]];
    label9.layer.borderColor = [[UIColor grayColor]CGColor];
    label9.layer.borderWidth = 0.8;
    [self addSubview:label9];
    self.endTime = [[UIButton alloc]initWithFrame:CGRectMake(431, 471, 208, 28)];
    [self.endTime setBackgroundImage:[UIImage imageNamed:@"下拉框.png"] forState:UIControlStateNormal];
    [self.endTime addTarget:self action:@selector(endTime:) forControlEvents:UIControlEventTouchUpInside];
    [self.endTime setTitle:[self.modifyDit valueForKey:@"endTime"] forState:UIControlStateNormal];
    self.endTime.titleLabel.font = [UIFont fontWithName:@"ArialMT" size:16];
    [self.endTime setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
    [self addSubview:self.endTime];
    //登记时间
    self.dJiTimeLabel = [[UILabel alloc]initWithFrame:CGRectMake(430, 520, 210, 30)];
    [self.dJiTimeLabel setBackgroundColor:[UIColor clearColor]];
    self.dJiTimeLabel.layer.borderColor = [[UIColor grayColor]CGColor];
    self.dJiTimeLabel.layer.borderWidth = 0.8;
    self.dJiTimeLabel.text = [self.modifyDit valueForKey:@"inputTime"];
    self.dJiTimeLabel.font = [UIFont fontWithName:@"ArialMT" size:16];
    [self.dJiTimeLabel setTextAlignment:NSTextAlignmentCenter];
    self.dJiTimeLabel.textColor = [UIColor grayColor];
    [self addSubview:self.dJiTimeLabel];
#pragma mark - 确定和取消按钮
    self.determineButton = [[UIButton alloc]initWithFrame:CGRectMake(500, 569, 75, 29)];
    [self.determineButton setBackgroundImage:[UIImage imageNamed:@"ht05-1.png"] forState:UIControlStateNormal];
    [self.determineButton setTitle:@"确  定" forState:UIControlStateNormal];
    [self.determineButton setTintColor:[UIColor whiteColor]];
    self.determineButton.titleLabel.font = [UIFont fontWithName:@"ArialMT" size:15];
    [self.determineButton addTarget:self action:@selector(determineButton:) forControlEvents:UIControlEventTouchUpInside];
    [self addSubview:self.determineButton];
    
    self.cancelButton = [[UIButton alloc]initWithFrame:CGRectMake(590, 569, 75, 30)];
    [self.cancelButton setTitle:@"取 消" forState:UIControlStateNormal];
    [self.cancelButton setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
    [self.cancelButton setBackgroundImage:[UIImage imageNamed:@"改-灰but.png"] forState:UIControlStateNormal];
    self.cancelButton.titleLabel.font = [UIFont fontWithName:@"ArialMT" size:15];
    [self.cancelButton addTarget:self action:@selector(cancelButton:) forControlEvents:UIControlEventTouchUpInside];
    [self addSubview:self.cancelButton];
    
    [self stateOfRepairChoose];
    
}
#pragma mark - 车牌查询按钮的回调
-(void)carPlateCxun:(id)sender
{
    //[self searchCarPlateView];
    
    webService *web=[[webService alloc] init];
    web.methodName = SEARCHJOBSHEET;
    NSMutableArray *paras = [[NSMutableArray alloc]init];
    [paras addObject:@"plateNumber"];
    [paras addObject:self.cPaiNumber.text];
    [paras addObject:@"currentCar"];
    [paras addObject:@"0"];
    [paras addObject:@"warrantyCar"];
    [paras addObject:@"0"];
    [paras addObject:@"isHonda"];
    [paras addObject:@"1"];
    [paras addObject:@"from"];
    [paras addObject:@"1"];
    [paras addObject:@"to"];
    [paras addObject:@"10"];
    [web commonGetSharedRequest:SEARCHJOBSHEET wsparas:paras];
    [SVProgressHUD showWithStatus:@"请等待...."];
}

#pragma mark - 工位选择按钮的回调
-(void)gWei:(id)sender
{
    if (!contentCon) {
        contentCon=[[popContentViewController alloc] initWithNibName:@"popContentViewController" bundle:nil];
    }
    contentCon.delegate = self;
    contentCon.btnSender=sender;
    self.popCon = [[UIPopoverController alloc] initWithContentViewController:contentCon];
    [DDPopoverBackgroundView setTintColor:[UIColor colorWithRed:234 green:248 blue:242 alpha:0.9]];
    [DDPopoverBackgroundView setArrowBase:30.0];//箭头
    [DDPopoverBackgroundView setArrowHeight:15.0];
    [DDPopoverBackgroundView setContentInset:1.0];
    [self.popCon setPopoverBackgroundViewClass:[DDPopoverBackgroundView class]];
    [self.popCon setPopoverContentSize:CGSizeMake(self.gWei.frame.size.width, 160)];
    [self.popCon presentPopoverFromRect:CGRectMake(0, 10, 105, 20) inView:sender permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES];
    
    self.gChangXZ = [[NSMutableArray alloc] init];
//    [self.gChangXZ addObject:@"< 空 >"];
    [self.gChangXZ addObject:@"修理工场"];
    [self.gChangXZ addObject:@"钣金工场"];
    [self.gChangXZ addObject:@"喷漆工场"];
    contentCon.list = self.gChangXZ;
    [contentCon.myTableView reloadData];
}
#pragma mark - 工位员工选择按钮的回调
-(void)gWeiName:(id)sender
{
    webService *webcon = [[webService alloc] init];
    webcon.methodName = GETWORKSTATIONLIST;
    NSMutableArray *arry = [NSMutableArray arrayWithObjects:@"workshopType",self.gChangNumber,nil];
    [webcon commonGetSharedRequest:GETWORKSTATIONLIST wsparas:arry];
//    NSLog(@"工场类型：%@",self.gChangNumber);
    
    if (!contentCon) {
        contentCon=[[popContentViewController alloc] initWithNibName:@"popContentViewController" bundle:nil];
    }
    contentCon.delegate = self;
    contentCon.btnSender=sender;
    self.popCon = [[UIPopoverController alloc] initWithContentViewController:contentCon];
    [DDPopoverBackgroundView setTintColor:[UIColor colorWithRed:234 green:248 blue:242 alpha:0.9]];
    [DDPopoverBackgroundView setArrowBase:30.0];//箭头
    [DDPopoverBackgroundView setArrowHeight:15.0];
    [DDPopoverBackgroundView setContentInset:1.0];
    [self.popCon setPopoverBackgroundViewClass:[DDPopoverBackgroundView class]];
    [self.popCon setPopoverContentSize:CGSizeMake(self.gWeiName.frame.size.width, 280)];
    [self.popCon presentPopoverFromRect:CGRectMake(0, 10, 105, 20) inView:sender permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES];
}
-(void)getworkStationListaaa:(NSNotification*)notification
{
//    NSLog(@"里面里面里面里面里面里面里面里面里面里面里面里面里面里面");

    NSDictionary *theJson = [NSJSONSerialization JSONObjectWithData:(NSData*)notification.object options:NSJSONReadingMutableLeaves error:Nil];
    NSMutableArray *gWeiArray = [[NSMutableArray alloc]init];
    self.workStationArray = [theJson objectForKey:@"workStationList"];
    for(int i=0;i<[[theJson objectForKey:@"workStationList"]count];i++)
    {
        [gWeiArray addObject:[[[theJson objectForKey:@"workStationList"]objectAtIndex:i]objectForKey:@"workStationName"]];
    }
    contentCon.list = nil;
    contentCon.list = gWeiArray;
    [contentCon.myTableView reloadData];
}

#pragma mark - 开始时间选择按钮的回调
-(void)beginTime:(id)sender
{
    _chooseDate = [[UIDatePicker alloc]initWithFrame:CGRectMake(0, 0, 280, 200)];
    _chooseDate.locale = [[NSLocale alloc] initWithLocaleIdentifier:NSLocalizedString(@"Chinese", @"")];
    _chooseDate.datePickerMode = UIDatePickerModeDateAndTime;
    NSDateFormatter *formatter = [[NSDateFormatter alloc]init];
    [formatter setDateFormat:@"yyyy-MM-dd HH:mm"];
    [_chooseDate setDate:[formatter dateFromString:self.beginTime.titleLabel.text]];
    [_chooseDate addTarget:self action:@selector(dateChanged2:) forControlEvents:UIControlEventValueChanged];
    //
    UIViewController *panleCon = [[UIViewController alloc] init];
    [panleCon.view addSubview:_chooseDate];
    self.popCon = [[UIPopoverController alloc] initWithContentViewController:panleCon];
    self.popCon.popoverContentSize = _chooseDate.frame.size;
    
    [self.popCon presentPopoverFromRect:CGRectMake(100, 0, 0, 30) inView:sender permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES];
}
-(void)dateChanged2:(id)sender
{
    NSDateFormatter *formatter = [[NSDateFormatter alloc]init];
    [formatter setDateFormat:@"yyyy-MM-dd HH:mm"];
    NSData *data = [NSString stringWithFormat:@"%@",[formatter stringFromDate:_chooseDate.date]];
    [self.beginTime setTitle:[NSString stringWithFormat:@"%@",data] forState:UIControlStateNormal];
}

#pragma mark - 服务顾问选择按钮的回调
-(void)fWuConsultant:(id)sender
{
    webService *webcon = [[webService alloc] init];
    webcon.methodName = GETSANAMELIST;
    [webcon commonGetSharedRequest:GETSANAMELIST wsparas:Nil];
    
    if (!contentCon) {
        contentCon=[[popContentViewController alloc] initWithNibName:@"popContentViewController" bundle:nil];
    }
    
    contentCon.delegate = self;
    contentCon.btnSender=sender;
    self.popCon = [[UIPopoverController alloc] initWithContentViewController:contentCon];
    [DDPopoverBackgroundView setTintColor:[UIColor colorWithRed:234 green:248 blue:242 alpha:0.9]];
    [DDPopoverBackgroundView setArrowBase:30.0];//箭头
    [DDPopoverBackgroundView setArrowHeight:15.0];
    [DDPopoverBackgroundView setContentInset:1.0];
    [self.popCon setPopoverBackgroundViewClass:[DDPopoverBackgroundView class]];
    [self.popCon setPopoverContentSize:CGSizeMake(self.fWuConsultant.frame.size.width, 280)];
    [self.popCon presentPopoverFromRect:CGRectMake(44, 10, 120, 20) inView:sender permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES];
}
-(void)getSaName:(NSNotification*)notification
{
    NSDictionary *theJson = [NSJSONSerialization JSONObjectWithData:(NSData*)notification.object options:NSJSONReadingMutableLeaves error:Nil];
    self.saArray = [theJson objectForKey:@"results"];
    NSMutableArray *carTypeArray=[[NSMutableArray alloc] init];
    
    for (int i=0; i<[[theJson objectForKey:@"results"] count]; i++) {
        
        [carTypeArray addObject: [[[theJson objectForKey:@"results"] objectAtIndex:i] objectForKey:@"saName"]];
    }
    
    contentCon.list = carTypeArray;
    
    [contentCon.myTableView reloadData];
    
}

#pragma mark -点击菜单回调方法
-(void)selectDelegate:(NSInteger)row btn:(UIButton *)btn
{
    if (btn == self.fWuConsultant)
    {
        self.saId = [[self.saArray objectAtIndex:row] objectForKey:@"saID"];
    }
    if(btn == self.gWeiName)
    {
        self.workStationNameId = [[self.workStationArray objectAtIndex:row]objectForKey:@"workStationId"];
    }
    else
    {
        
    }
    if(btn == self.gWei)
    {
        self.gWeiName.titleLabel.text = @"请选择";
        if([[self.gChangXZ objectAtIndex:row] isEqualToString:@"修理工场"])
        {
            self.gChangNumber = @"0";
        }
        if([[self.gChangXZ objectAtIndex:row] isEqualToString:@"钣金工场"])
        {
            self.gChangNumber = @"1";
        }
        if([[self.gChangXZ objectAtIndex:row] isEqualToString:@"喷漆工场"])
        {
            self.gChangNumber = @"2";
        }        
    }
    [self.popCon dismissPopoverAnimated:YES];
    self.popCon = nil;
}
#pragma mark - 结束时间选择按钮的回调
-(void)endTime:(id)sender
{
    _chooseDate = [[UIDatePicker alloc]initWithFrame:CGRectMake(0, 0, 280, 200)];
    _chooseDate.locale = [[NSLocale alloc] initWithLocaleIdentifier:NSLocalizedString(@"Chinese", @"")];
    _chooseDate.datePickerMode = UIDatePickerModeDateAndTime;
    [_chooseDate addTarget:self action:@selector(dateChanged:) forControlEvents:UIControlEventValueChanged];
    //
    UIViewController *panleCon = [[UIViewController alloc] init];
    [panleCon.view addSubview:_chooseDate];
    self.popCon = [[UIPopoverController alloc] initWithContentViewController:panleCon];
    self.popCon.popoverContentSize = _chooseDate.frame.size;
    
    [self.popCon presentPopoverFromRect:CGRectMake(100, 0, 0, 30) inView:sender permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES];
}
-(void)dateChanged:(id)sender
{
    NSDateFormatter *formatter = [[NSDateFormatter alloc]init];
    [formatter setDateFormat:@"yyyy-MM-dd HH:mm"];
    NSData *data = [NSString stringWithFormat:@"%@",[formatter stringFromDate:_chooseDate.date]];
    [self.endTime setTitle:[NSString stringWithFormat:@"%@",data] forState:UIControlStateNormal];
}
#pragma mark - 获取数据的字典
-(void)tijiaoDictionary
{
    self.SearchDataDit = [[NSMutableDictionary alloc]initWithCapacity:10];
    [self.SearchDataDit setObject:self.yYueNumber.text forKey:@"BOOKING_ORDER_NO"];
    //[self.SearchDataDit setObject:@"ZZZ901" forKey:@"recruitTypeName"];
    if(self.cPaiNumber.text == nil || [self.cPaiNumber.text isEqualToString:@""])
    {
        self.cPaiNumber.text = @"";
    }
    [self.SearchDataDit setObject:self.cPaiNumber.text forKey:@"PLATE_NUMBER"];
    [self.SearchDataDit setObject:self.kHuName.text forKey:@"CUSTOMER_NAME"];
    
    [self.SearchDataDit setObject:self.yHuSpeak.text forKey:@"CUSTOMER_STATEMENTS"];
    
    //[self.SearchDataDit setObject:self.gWei.titleLabel.text forKey:@"factoryName"];
    //<Data name="SERIES" type="string" />先选车系
    //<Data name="MODEL" type="string" />再选车型
    //<Data name="BOOKING_TYPE_CODE" type="string" />预约类别
    
    
    //工位
    //[self.SearchDataDit setObject:self.workStationNameId forKey:@"workStationId"];
    
    [self.SearchDataDit setObject:self.beginTime.titleLabel.text forKey:@"BOOKING_COME_TIME"];
    [self.SearchDataDit setObject:self.dJPeopleLabel.text forKey:@"OPERATOR"];
    if(self.cJiaNumber.text == nil || [self.cJiaNumber.text isEqualToString:@""])
    {
        self.cJiaNumber.text = @"";
    }
    [self.SearchDataDit setObject:self.cJiaNumber.text forKey:@"VIN"];
    [self.SearchDataDit setObject:self.lXiPhone.text forKey:@"MOBILE"];
    //服务顾问
    [self.SearchDataDit setObject:self.saId forKey:@"SA_ID"];
    //结束时间
    //[self.SearchDataDit setObject:self.endTime.titleLabel.text forKey:@"endTime"];
    //登记时间
    [self.SearchDataDit setObject:self.dJiTimeLabel.text forKey:@"CREATE_DATE"];
    
    self.chooseArray = [[NSMutableArray alloc]initWithObjects:[NSNumber numberWithBool:_chooes1],[NSNumber numberWithBool:_chooes2],[NSNumber numberWithBool:_chooes3],[NSNumber numberWithBool:_chooes4],[NSNumber numberWithBool:_chooes5],[NSNumber numberWithBool:_chooes6],[NSNumber numberWithBool:_chooes7], nil];
    
    NSString *str = @"";
    for(int i = 0;i<[self.chooseArray count];i++)
    {
        if ([[self.chooseArray objectAtIndex:i] boolValue] == YES)
        {
            str = [str stringByAppendingFormat:@"%i,",i+1];
        }
        if(str.length == 0 )
        {
            self.weiXiuTypeBC = str;
        }else
        {
            self.weiXiuTypeBC=[str substringToIndex:[str length]-1];
        }
    }
    [self.SearchDataDit setObject:self.weiXiuTypeBC forKey:@"repairTypeCode"];
    
//    NSLog(@"你他妈为什么不变？：%@",self.SearchDataDit);
    
}
#pragma mark - 确定按钮的回调
-(void)determineButton:(id)sender
{
    if(self.kHuName.text == nil)
    {
        UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"请选择客户名称" message:nil delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"确定", nil];
        [alertView show];
    }
    else if(self.lXiPhone.text == nil)
    {
        UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"请输入联系电话" message:nil delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"确定", nil];
        [alertView show];
    }
    else if(self.yHuSpeak.text == nil)
    {
        UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"请输入用户陈述" message:nil delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"确定", nil];
        [alertView show];
    }
    else if([self.gWeiName.titleLabel.text isEqualToString:@"请选择"]||[self.gWei.titleLabel.text isEqualToString:@"请选择"])
    {
        UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"请选择工位" message:nil delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"确定", nil];
        [alertView show];
    }
    else if(self.fWuConsultant.tag == 100+1)
    {
        for (int i=0; i<[self.saArray count]; i++)
        {
            NSString *chuanSaName = [[self.modifyDit objectForKey:@"saName"]objectAtIndex:i];
            NSString *saNamgNumber = [NSString stringWithFormat:@"%d",[self.saArray indexOfObject:chuanSaName]];
//            NSLog(@"~>~>~>~>~>:=>%@",saNamgNumber);
        }
    }
    
    else
    {
//        webService *web = [[webService alloc]init];
//        web.methodName = UPDATEPRECONTRACTMANAGE;
//        
//        [web commonPostSharedRequest:UPDATEPRECONTRACTMANAGE psotDic:self.SearchDataDit];
        
        [self tijiaoDictionary];
        [MyAFNetWorkManager postWithParam:self.SearchDataDit andAction:@"MAINTAIN_BOOKING_ORDER_FOR_PAD" finish:^(NSData *data, NSDictionary *obj, NSError *error) {
            if (!error) {
                
            }
            else{
                [SVProgressHUD showErrorWithStatus:error.localizedDescription];
            }
        }];
    }
}
-(void)updatePrecontractManage:(NSNotification *)notification
{
    NSMutableDictionary *theJson = [NSJSONSerialization JSONObjectWithData:(NSData *)notification.object options:NSJSONReadingMutableLeaves error:nil];
    if([[theJson valueForKey:@"error_code"] intValue])
    {
        UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:[theJson valueForKey:@"error_msg"] message:nil delegate:self cancelButtonTitle:@"确定" otherButtonTitles:nil, nil];
        [alertView show];
    }
    else
    {
        UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"修改成功！" message:nil delegate:self cancelButtonTitle:@"确定" otherButtonTitles:nil, nil];
        
        [alertView show];
    [[NSNotificationCenter defaultCenter] postNotificationName:@"sucess" object:nil];
    }
}
#pragma mark - 取消按钮的回调
-(void)cancelButton:(id)sender
{
    [self removeFromSuperview];
    [[NSNotificationCenter defaultCenter]removeObserver:self name:GETWORKSTATIONLIST object:nil];
}
#pragma mark - 是否选择首次保养的回调
-(void)firstChoose:(id)sender
{
    if(_chooes1 == YES)
    {
        [self.firstChoose setImage:[UIImage imageNamed:@"对号框.png"] forState:UIControlStateNormal];
        _chooes1 = NO;
    }
    else
    {
        [self.firstChoose setImage:[UIImage imageNamed:@"对号.png"] forState:UIControlStateNormal];
        _chooes1 = YES;
    }
    [self.chooseArray addObject:[NSNumber numberWithBool:_chooes1]];
}
#pragma mark - 是否选择年检保养的回调
-(void)nJianChoose:(id)sender
{
    if(_chooes3 == YES)
    {
        _chooes3 = NO;
        [self.nJianChoose setImage:[UIImage imageNamed:@"对号框.png"] forState:UIControlStateNormal];
    }
    else
    {
        _chooes3 = YES;
        [self.nJianChoose setImage:[UIImage imageNamed:@"对号.png"] forState:UIControlStateNormal];
    }
    [self.chooseArray addObject:[NSNumber numberWithBool:_chooes3]];
}
#pragma mark - 是否选择钣金的回调
-(void)bJinChoose:(id)sender
{
    if(_chooes5 == YES)
    {
        _chooes5 = NO;
        [self.bJinChoose setImage:[UIImage imageNamed:@"对号框.png"] forState:UIControlStateNormal];
    }
    else
    {
        _chooes5 = YES;
        [self.bJinChoose setImage:[UIImage imageNamed:@"对号.png"] forState:UIControlStateNormal];
    }
    [self.chooseArray addObject:[NSNumber numberWithBool:_chooes5]];
}
#pragma mark - 是否选择精品的回调
-(void)jPinChoose:(id)sender
{
    if(_chooes7 == YES)
    {
        _chooes7 = NO;
        [self.jPinChoose setImage:[UIImage imageNamed:@"对号框.png"] forState:UIControlStateNormal];
    }
    else
    {
        _chooes7 = YES;
        [self.jPinChoose setImage:[UIImage imageNamed:@"对号.png"] forState:UIControlStateNormal];
    }
    [self.chooseArray addObject:[NSNumber numberWithBool:_chooes7]];
}
#pragma mark - 是否选择定期保养的回调
-(void)dQiChoose:(id)sender
{
    if(_chooes2 == YES)
    {
        _chooes2 = NO;
        [self.dQiChoose setImage:[UIImage imageNamed:@"对号框.png"] forState:UIControlStateNormal];
    }
    else
    {
        _chooes2 = YES;
        [self.dQiChoose setImage:[UIImage imageNamed:@"对号.png"] forState:UIControlStateNormal];
    }
    [self.chooseArray addObject:[NSNumber numberWithBool:_chooes2]];
}
#pragma mark - 是否选择一般修理的回调
-(void)yBanChoose:(id)sender
{
    if(_chooes4 == YES)
    {
        _chooes4 = NO;
        [self.yBanChoose setImage:[UIImage imageNamed:@"对号框.png"] forState:UIControlStateNormal];
    }
    else
    {
        _chooes4 = YES;
        [self.yBanChoose setImage:[UIImage imageNamed:@"对号.png"] forState:UIControlStateNormal];
    }
    [self.chooseArray addObject:[NSNumber numberWithBool:_chooes4]];
}
#pragma mark - 是否选择喷漆的回调
-(void)pQiChoose:(id)sender
{
    if(_chooes6 == YES)
    {
        _chooes6 = NO;
        [self.pQiChoose setImage:[UIImage imageNamed:@"对号框.png"] forState:UIControlStateNormal];
    }
    else
    {
        _chooes6 = YES;
        [self.pQiChoose setImage:[UIImage imageNamed:@"对号.png"] forState:UIControlStateNormal];
    }
    [self.chooseArray addObject:[NSNumber numberWithBool:_chooes6]];
}

#pragma mark - 维修状态选择
-(void)stateOfRepairChoose
{
    //首次保养
    self.firstChoose = [UIButton buttonWithType:UIButtonTypeCustom];
    [self.firstChoose setFrame:CGRectMake(10, 5, 30, 31)];
    [self.firstChoose setImage:[UIImage imageNamed:@"对号框.png"] forState:UIControlStateNormal];
    [self.firstChoose addTarget:self action:@selector(firstChoose:) forControlEvents:UIControlEventTouchUpInside];
    [self.xLiType addSubview:self.firstChoose];
    //年检保养
    self.nJianChoose = [UIButton buttonWithType:UIButtonTypeCustom];
    [self.nJianChoose setFrame:CGRectMake(160, 5, 30, 31)];
    [self.nJianChoose setImage:[UIImage imageNamed:@"对号框.png"] forState:UIControlStateNormal];
    [self.nJianChoose addTarget:self action:@selector(nJianChoose:) forControlEvents:UIControlEventTouchUpInside];
    [self.xLiType addSubview:self.nJianChoose];
    //钣金
    self.bJinChoose = [UIButton buttonWithType:UIButtonTypeCustom];
    [self.bJinChoose setFrame:CGRectMake(300, 5, 30, 31)];
    [self.bJinChoose setImage:[UIImage imageNamed:@"对号框.png"] forState:UIControlStateNormal];
    [self.bJinChoose addTarget:self action:@selector(bJinChoose:) forControlEvents:UIControlEventTouchUpInside];
    [self.xLiType addSubview:self.bJinChoose];
    //精品
    self.jPinChoose = [UIButton buttonWithType:UIButtonTypeCustom];
    [self.jPinChoose setFrame:CGRectMake(410, 5, 30, 31)];
    [self.jPinChoose setImage:[UIImage imageNamed:@"对号框.png"] forState:UIControlStateNormal];
    [self.jPinChoose addTarget:self action:@selector(jPinChoose:) forControlEvents:UIControlEventTouchUpInside];
    [self.xLiType addSubview:self.jPinChoose];
    //定期保养
    self.dQiChoose = [UIButton buttonWithType:UIButtonTypeCustom];
    [self.dQiChoose setFrame:CGRectMake(10, 40, 30, 31)];
    [self.dQiChoose setImage:[UIImage imageNamed:@"对号框.png"] forState:UIControlStateNormal];
    [self.dQiChoose addTarget:self action:@selector(dQiChoose:) forControlEvents:UIControlEventTouchUpInside];
    [self.xLiType addSubview:self.dQiChoose];
    //一般修理
    self.yBanChoose = [UIButton buttonWithType:UIButtonTypeCustom];
    [self.yBanChoose setFrame:CGRectMake(160, 40, 30, 31)];
    [self.yBanChoose setImage:[UIImage imageNamed:@"对号框.png"] forState:UIControlStateNormal];
    [self.yBanChoose addTarget:self action:@selector(yBanChoose:) forControlEvents:UIControlEventTouchUpInside];
    [self.xLiType addSubview:self.yBanChoose];
    //喷漆
    self.pQiChoose = [UIButton buttonWithType:UIButtonTypeCustom];
    [self.pQiChoose setFrame:CGRectMake(300, 40, 30, 31)];
    [self.pQiChoose setImage:[UIImage imageNamed:@"对号框.png"] forState:UIControlStateNormal];
    [self.pQiChoose addTarget:self action:@selector(pQiChoose:) forControlEvents:UIControlEventTouchUpInside];
    [self.xLiType addSubview:self.pQiChoose];
    
    UILabel *label1 = [[UILabel alloc]initWithFrame:CGRectMake(45, 5, 80, 35)];
    label1.text = @"首保";
    label1.backgroundColor = [UIColor clearColor];
    label1.textColor = [UIColor grayColor];
    label1.font = [UIFont fontWithName:@"ArialMT" size:14];
    [self.xLiType addSubview:label1];
    
    UILabel *label2 = [[UILabel alloc]initWithFrame:CGRectMake(195, 5, 80, 35)];
    label2.text = @"年检保养";
    label2.backgroundColor = [UIColor clearColor];
    label2.textColor = [UIColor grayColor];
    label2.font = [UIFont fontWithName:@"ArialMT" size:14];
    [self.xLiType addSubview:label2];
    
    UILabel *label3 = [[UILabel alloc]initWithFrame:CGRectMake(335, 5, 80, 35)];
    label3.text = @"钣金";
    label3.backgroundColor = [UIColor clearColor];
    label3.textColor = [UIColor grayColor];
    label3.font = [UIFont fontWithName:@"ArialMT" size:14];
    [self.xLiType addSubview:label3];
    
    UILabel *label4 = [[UILabel alloc]initWithFrame:CGRectMake(445, 5, 80, 35)];
    label4.text = @"精品";
    label4.backgroundColor = [UIColor clearColor];
    label4.textColor = [UIColor grayColor];
    label4.font = [UIFont fontWithName:@"ArialMT" size:14];
    [self.xLiType addSubview:label4];
    
    UILabel *label5 = [[UILabel alloc]initWithFrame:CGRectMake(45, 40, 80, 35)];
    label5.text = @"定期保养";
    label5.backgroundColor = [UIColor clearColor];
    label5.textColor = [UIColor grayColor];
    label5.font = [UIFont fontWithName:@"ArialMT" size:14];
    [self.xLiType addSubview:label5];
    
    UILabel *label6 = [[UILabel alloc]initWithFrame:CGRectMake(195, 40, 80, 35)];
    label6.text = @"一般修理";
    label6.backgroundColor = [UIColor clearColor];
    label6.textColor = [UIColor grayColor];
    label6.font = [UIFont fontWithName:@"ArialMT" size:14];
    [self.xLiType addSubview:label6];
    
    UILabel *label7 = [[UILabel alloc]initWithFrame:CGRectMake(335, 40, 80, 35)];
    label7.text = @"喷漆";
    label7.backgroundColor = [UIColor clearColor];
    label7.textColor = [UIColor grayColor];
    label7.font = [UIFont fontWithName:@"ArialMT" size:14];
    [self.xLiType addSubview:label7];
    
    self.chooseTapy = [self.modifyDit valueForKey:@"repairTypeName"];
//    NSLog(@"$$$%@",self.chooseTapy);
    if([self.chooseTapy rangeOfString:@"1"].length == 1)
    {
        _chooes1 = YES;
        [self.chooseArray addObject:[NSNumber numberWithBool:_chooes1]];
        [self.firstChoose setImage:[UIImage imageNamed:@"对号.png"] forState:UIControlStateNormal];
    }
    if([self.chooseTapy rangeOfString:@"3"].length == 1)
    {
        _chooes3 = YES;
        [self.chooseArray addObject:[NSNumber numberWithBool:_chooes3]];
        [self.nJianChoose setImage:[UIImage imageNamed:@"对号.png"] forState:UIControlStateNormal];
    }
    if([self.chooseTapy rangeOfString:@"5"].length == 1)
    {
        _chooes5 = YES;
        [self.chooseArray addObject:[NSNumber numberWithBool:_chooes5]];
        [self.bJinChoose setImage:[UIImage imageNamed:@"对号.png"] forState:UIControlStateNormal];
    }
    if([self.chooseTapy rangeOfString:@"7"].length == 1)
    {
        _chooes7 = YES;
        [self.chooseArray addObject:[NSNumber numberWithBool:_chooes7]];
        [self.jPinChoose setImage:[UIImage imageNamed:@"对号.png"] forState:UIControlStateNormal];
    }
    if([self.chooseTapy rangeOfString:@"2"].length == 1)
    {
        _chooes2 = YES;
        [self.chooseArray addObject:[NSNumber numberWithBool:_chooes2]];
        [self.dQiChoose setImage:[UIImage imageNamed:@"对号.png"] forState:UIControlStateNormal];
    }
    if([self.chooseTapy rangeOfString:@"4"].length == 1)
    {
        _chooes4 = YES;
        [self.chooseArray addObject:[NSNumber numberWithBool:_chooes4]];
        [self.yBanChoose setImage:[UIImage imageNamed:@"对号.png"] forState:UIControlStateNormal];
    }
    if([self.chooseTapy rangeOfString:@"6"].length == 1)
    {
        _chooes6 = YES;
        [self.chooseArray addObject:[NSNumber numberWithBool:_chooes6]];
        [self.pQiChoose setImage:[UIImage imageNamed:@"对号.png"] forState:UIControlStateNormal];
    }
}
#pragma mark - 查询车牌弹出窗口
-(void)searchCarPlateView
{
    self.popSearchView = [[UIView alloc]initWithFrame:CGRectMake(20, 20, self.frame.size.width-20-20, self.frame.size.height-20-20)];
    [self.popSearchView setBackgroundColor:[UIColor whiteColor]];
    // [self addSubview:self.popSearchView];
    
    self.searchPlateView = [[UITableView alloc]initWithFrame:CGRectMake(20, 100, self.popSearchView.frame.size.width-20-20, self.popSearchView.frame.size.height-100-70)];
    [self.searchPlateView setDelegate:self];
    [self.searchPlateView setDataSource:self];
    [self.popSearchView addSubview:self.searchPlateView];
    [self addSubview:self.popSearchView];
    
    UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(20, 55, 650, 40)];
    label.text = @"              车牌号码                               客户名称                               车架号        ";
    label.backgroundColor = [UIColor clearColor];
    label.textColor = [UIColor grayColor];
    label.font = [UIFont fontWithName:@"ArialMT" size:16];
    [self.popSearchView addSubview:label];
    
    UIButton *doneBut = [[UIButton alloc]initWithFrame:CGRectMake(563, 5, 75, 35)];
    [doneBut setTitle:@"取 消" forState:UIControlStateNormal];
    [doneBut setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
    [doneBut setBackgroundImage:[UIImage imageNamed:@"改-灰but.png"] forState:UIControlStateNormal];
    doneBut.titleLabel.font = [UIFont fontWithName:@"ArialMT" size:15];
    [doneBut addTarget:self action:@selector(doneBut:) forControlEvents:UIControlEventTouchUpInside];
    [self.popSearchView addSubview:doneBut];
}
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return [self.listRowIndex count];
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    NSInteger row = [indexPath row];
    static NSString *indetfire = @"cell";
    SearchTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:indetfire];
    if(nil == cell)
    {
        cell = [[SearchTableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:indetfire];
        tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    }
    cell.plateNumber.text = [[self.listRowIndex objectAtIndex:row]objectForKey:@"plateNumber"];
    cell.customerName.text = [[self.listRowIndex objectAtIndex:row]objectForKey:@"customerName"];
    cell.carFrame.text = [[self.listRowIndex objectAtIndex:row]objectForKey:@"vin"];
    
    return cell;
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 45;
}
-(void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
{
    if(indexPath.row%2 == 1)
    {
        cell.backgroundColor = [UIColor whiteColor];
    }
    else
    {
        cell.backgroundColor = [[UIColor alloc]initWithRed:226.00/255 green:226.00/255 blue:226.00/255 alpha:1];
    }
    cell.selectionStyle = UITableViewCellSelectionStyleNone;;
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    self.cPaiNumber.text = [[self.listRowIndex objectAtIndex:indexPath.row]objectForKey:@"plateNumber"];
    self.cJiaNumber.text = [[self.listRowIndex objectAtIndex:indexPath.row]objectForKey:@"vin"];
    self.kHuName.text = [[self.listRowIndex objectAtIndex:indexPath.row]objectForKey:@"customerName"];
    [self.popSearchView removeFromSuperview];
}
-(void)doneBut:(id)sender
{
    [self.popSearchView removeFromSuperview];
}

-(void)fixedTitle
{
    UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(290, 20, 200, 40)];
    label.text = @"预约编辑";
    label.backgroundColor = [UIColor clearColor];
    label.textColor = [UIColor grayColor];
    label.font = [UIFont fontWithName:@"ArialMT" size:22];
    [self addSubview:label];
    
    UIImageView *imageline= [[UIImageView alloc]initWithFrame:CGRectMake(15, 60, 670, 2)];
    imageline.image = [UIImage imageNamed:@"红色分割线.png"];
    [self addSubview:imageline];
    
    UILabel *label1 = [[UILabel alloc]initWithFrame:CGRectMake(35, 100, 80, 30)];
    label1.text = @"预  约  号:";
    label1.backgroundColor = [UIColor clearColor];
    label1.textColor = [UIColor grayColor];
    label1.font = [UIFont fontWithName:@"ArialMT" size:16];
    [self addSubview:label1];
    
    UILabel *label2 = [[UILabel alloc]initWithFrame:CGRectMake(35, 150, 80, 30)];
    label2.text = @"车牌号码:";
    label2.backgroundColor = [UIColor clearColor];
    label2.textColor = [UIColor grayColor];
    label2.font = [UIFont fontWithName:@"ArialMT" size:16];
    [self addSubview:label2];
    
    UILabel *label3 = [[UILabel alloc]initWithFrame:CGRectMake(35, 200, 80, 30)];
    label3.text = @"客户名称:";
    label3.backgroundColor = [UIColor clearColor];
    label3.textColor = [UIColor grayColor];
    label3.font = [UIFont fontWithName:@"ArialMT" size:16];
    [self addSubview:label3];
    
    UILabel *label4 = [[UILabel alloc]initWithFrame:CGRectMake(35, 250, 80, 30)];
    label4.text = @"用户陈述:";
    label4.backgroundColor = [UIColor clearColor];
    label4.textColor = [UIColor grayColor];
    label4.font = [UIFont fontWithName:@"ArialMT" size:16];
    [self addSubview:label4];
    
    UILabel *label5 = [[UILabel alloc]initWithFrame:CGRectMake(35, 330, 80, 30)];
    label5.text = @"修理类型:";
    label5.backgroundColor = [UIColor clearColor];
    label5.textColor = [UIColor grayColor];
    label5.font = [UIFont fontWithName:@"ArialMT" size:16];
    [self addSubview:label5];
    
    UILabel *label6 = [[UILabel alloc]initWithFrame:CGRectMake(35, 420, 80, 30)];
    label6.text = @"工       位:";
    label6.backgroundColor = [UIColor clearColor];
    label6.textColor = [UIColor grayColor];
    label6.font = [UIFont fontWithName:@"ArialMT" size:16];
    [self addSubview:label6];
    
    UILabel *label7 = [[UILabel alloc]initWithFrame:CGRectMake(35, 470, 80, 30)];
    label7.text = @"开始时间:";
    label7.backgroundColor = [UIColor clearColor];
    label7.textColor = [UIColor grayColor];
    label7.font = [UIFont fontWithName:@"ArialMT" size:16];
    [self addSubview:label7];
    
    UILabel *label8 = [[UILabel alloc]initWithFrame:CGRectMake(35, 520, 80, 30)];
    label8.text = @"登  记  人:";
    label8.backgroundColor = [UIColor clearColor];
    label8.textColor = [UIColor grayColor];
    label8.font = [UIFont fontWithName:@"ArialMT" size:16];
    [self addSubview:label8];
    
    UILabel *label9 = [[UILabel alloc]initWithFrame:CGRectMake(350, 100, 80, 30)];
    label9.text = @"预约类型:";
    label9.backgroundColor = [UIColor clearColor];
    label9.textColor = [UIColor grayColor];
    label9.font = [UIFont fontWithName:@"ArialMT" size:16];
    [self addSubview:label9];
    
    UILabel *label10 = [[UILabel alloc]initWithFrame:CGRectMake(350, 150, 80, 30)];
    label10.text = @"车  架  号:";
    label10.backgroundColor = [UIColor clearColor];
    label10.textColor = [UIColor grayColor];
    label10.font = [UIFont fontWithName:@"ArialMT" size:16];
    [self addSubview:label10];
    
    UILabel *label11 = [[UILabel alloc]initWithFrame:CGRectMake(350, 200, 80, 30)];
    label11.text = @"联系电话:";
    label11.backgroundColor = [UIColor clearColor];
    label11.textColor = [UIColor grayColor];
    label11.font = [UIFont fontWithName:@"ArialMT" size:16];
    [self addSubview:label11];
    
    UILabel *label12 = [[UILabel alloc]initWithFrame:CGRectMake(350, 420, 80, 30)];
    label12.text = @"服务顾问:";
    label12.backgroundColor = [UIColor clearColor];
    label12.textColor = [UIColor grayColor];
    label12.font = [UIFont fontWithName:@"ArialMT" size:16];
    [self addSubview:label12];
    
    UILabel *label13 = [[UILabel alloc]initWithFrame:CGRectMake(350, 470, 80, 30)];
    label13.text = @"结束时间:";
    label13.backgroundColor = [UIColor clearColor];
    label13.textColor = [UIColor grayColor];
    label13.font = [UIFont fontWithName:@"ArialMT" size:16];
    [self addSubview:label13];
    
    UILabel *label14 = [[UILabel alloc]initWithFrame:CGRectMake(350, 520, 80, 30)];
    label14.text = @"登记时间:";
    label14.backgroundColor = [UIColor clearColor];
    label14.textColor = [UIColor grayColor];
    label14.font = [UIFont fontWithName:@"ArialMT" size:16];
    [self addSubview:label14];
}
-(void)addNotification
{
    //预约修改
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(updatePrecontractManage:) name:UPDATEPRECONTRACTMANAGE object:Nil];
    //服务顾问
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(getSaName:) name:GETSANAMELIST object:Nil];
    //工位
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(getworkStationListaaa:) name:GETWORKSTATIONLIST object:Nil];
    //车牌查询消息
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(searchUpdataUI2:) name:SEARCHJOBSHEET object:nil];
}
-(void)searchUpdataUI2:(NSNotification *)notifcation
{
    NSMutableDictionary *Json= [NSJSONSerialization JSONObjectWithData:(NSData*)notifcation.object options:NSJSONReadingMutableLeaves error:Nil];
    self.listRowIndex = [Json objectForKey:@"results"];
    [self searchCarPlateView];
    [self.searchPlateView reloadData];
    [SVProgressHUD dismiss];
}
-(void)removeNotification
{
    [[NSNotificationCenter defaultCenter]removeObserver:self];
}
//输入框的代理方法
-(BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string
{
    NSCharacterSet *cs;
    cs = [[NSCharacterSet characterSetWithCharactersInString:NUMBERS]invertedSet];
    NSString *filtered = [[string componentsSeparatedByCharactersInSet:cs]componentsJoinedByString:@""];
    BOOL canChange = [string isEqualToString:filtered];
    return canChange;
}

/*
 // Only override drawRect: if you perform custom drawing.
 // An empty implementation adversely affects performance during animation.
 - (void)drawRect:(CGRect)rect
 {
 // Drawing code
 }
 */

@end
